package com.example.springboot.subscribe;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @program: 12-springboot-rabbitmq
 * @description: MsgSender
 * @author: Yuwl
 * @create: 2019-12-27 17:25
 **/
@Component
public class MsgSenderFanout {

	@Autowired
	private AmqpTemplate amqpTemplate;

	/**
	 * send1方法会匹配到topic.#和topic.message，两个Receiver都可以收到消息
	 */
	public void send() {
		String context = "hi, fanout message ";
		System.out.println("Sender : " + context);
		//订阅模式无路由
		this.amqpTemplate.convertAndSend("mybootfanoutExchange", "", context);
	}

}
